package com.example.BlockChain.entity;

public class TChainData {

    /**
     * 数据记录的唯一标识 ID
     */
    private int id;

    /**
     * 溯源码
     */
    private String code;

    /**
     * 数据的发送方地址
     */
    private String fromAddress;

    /**
     * 数据的接收方地址
     */
    private String toAddress;
    /**
     * 上链数据的具体内容
     */
    private String content;
    /**
     * 操作类型
     * - 1: 消费者下单
     * - 2: 商家接单
     * - 3: 配送员配送
     */
    private int operationType;

    /**
     * 数据记录的哈希值
     * - 确保唯一性
     */
    private String hashNo;

    /**
     * 所属区块的索引
     * - 表示数据记录所在的区块号
     */
    private String blockIndex;

    /**
     * 数据创建时间
     * - 格式为：yyyy-MM-dd HH:mm:ss
     */
    private String createTime;

    /**
     * 上链状态
     * - 0: 未上链
     * - 1: 已上链
     */
    private String chainStatus;

    // ================== 静态初始化方法 ==================
    public static TChainData createDefault() {
        TChainData defaultData = new TChainData();
        defaultData.id = 0; // ID 设置为 0，表示未初始化
        defaultData.code = null;
        defaultData.fromAddress = null;
        defaultData.toAddress = null;
        defaultData.content = null;
        defaultData.operationType = 0; // 操作类型设置为 0
        defaultData.hashNo = null;
        defaultData.blockIndex = null;
        defaultData.createTime = null;
        defaultData.chainStatus = null;
        return defaultData;
    }

    // ================== Getter 和 Setter 方法 ==================

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getFromAddress() {
        return fromAddress;
    }

    public void setFromAddress(String fromAddress) {
        this.fromAddress = fromAddress;
    }

    public String getToAddress() {
        return toAddress;
    }

    public void setToAddress(String toAddress) {
        this.toAddress = toAddress;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getOperationType() {
        return operationType;
    }

    public void setOperationType(int operationType) {
        this.operationType = operationType;
    }

    public String getHashNo() {
        return hashNo;
    }

    public void setHashNo(String hashNo) {
        this.hashNo = hashNo;
    }

    public String getBlockIndex() {
        return blockIndex;
    }

    public void setBlockIndex(String blockIndex) {
        this.blockIndex = blockIndex;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getChainStatus() {
        return chainStatus;
    }

    public void setChainStatus(String chainStatus) {
        this.chainStatus = chainStatus;
    }

    @Override
    public String toString() {
        return "TChainData{" +
                "id=" + id +
                ", code='" + code + '\'' +
                ", fromAddress='" + fromAddress + '\'' +
                ", toAddress='" + toAddress + '\'' +
                ", content='" + content + '\'' +
                ", operationType=" + operationType +
                ", hashNo='" + hashNo + '\'' +
                ", blockIndex='" + blockIndex + '\'' +
                ", createTime='" + createTime + '\'' +
                ", chainStatus='" + chainStatus + '\'' +
                '}';
    }
}
